package akatsuki.janalyzercode.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;

import akatsuki.janalyzercode.view.JAnalyzerCodeView;

public class ActivarJac implements IWorkbenchWindowActionDelegate {
	private IWorkbenchWindow window;
	
	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init(IWorkbenchWindow window) {
		// TODO Auto-generated method stub
		this.window = window;
	}

	@Override
	public void run(IAction action) {
		// TODO Auto-generated method stub
		boolean rpta;
		rpta = MessageDialog.openQuestion(window.getShell(), "Consulta", "Desea activar JAC");
		if (rpta){
			// Get the active page
			if (window == null)
				return;
			IWorkbenchPage page = window.getActivePage();
			if (page == null)
				return;
			
			// Open and activate the Favorites view
			try {
				page.showView(JAnalyzerCodeView.ID);
			} catch (PartInitException e) {
				
			}
		}

	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
		// TODO Auto-generated method stub

	}

}
